package com.beyond.exception;

import java.sql.SQLException;

public class XException extends Exception {

	private static final long serialVersionUID = 1L;
	
	private String errorCode;
	private String message;
	private Throwable cause;
	
	//=============================构造方法=========================
	public XException(){
		super();
	}
	
	public XException(String message){
		super(message);
		this.message = message;
	}
	
	public XException(Throwable cause){
		super(cause);
		this.message = cause.getMessage();
		this.cause = cause;
		if(cause instanceof SQLException){
			SQLException sqle = (SQLException)cause;
			this.errorCode = "" + sqle.getErrorCode();
		}
	}
	
	public XException(String message, Throwable cause){
		super(message, cause);
		this.message = message;
		this.cause = cause;
		if(cause instanceof SQLException){
			SQLException sqle = (SQLException)cause;
			this.errorCode = "" + sqle.getErrorCode();
		}
	}
	
	//=============================构造方法  结束=========================
	
	
	public String getErrorCode() {
		return errorCode;
	}
	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public Throwable getCause() {
		return cause;
	}
	public void setCause(Throwable cause) {
		this.cause = cause;
	}
}
